import fetch from 'common/src/utils/fetch'
import UTILS from "common/src/utils/utils";

/**
 * 保存
 */
function save(idList) {
    return fetch({
        url: '/api/electionservice/microCourseCharge/save',
        method: 'post',
        data: idList
    });
}

/**
 * 获取收费标准
 */
function get(id) {
    return fetch({
        url: `/api/electionservice/microCourseCharge/getMicroCourseCharge/${id}`,
        method: 'get'
    });
}

/**
 * 导出
 */
function exportRollBookList(data) {
    return fetch({
        url: '/api/electionservice/microElcFeeStatistics/teachingClassResult/export',
        method: 'post',
        data: data
    });
}

/**
 *
 * 查询是否导出完成
 */
function exportStatus(key) {
    return fetch({
        url: '/api/electionservice/microElcFeeStatistics/result/'+key,
        method: 'get'
    });
}

/**
 * 预览点名册
 */
function previewRollBookList(teachingClassId, calendarId) {
    return fetch({
        url:
            '/api/electionservice/microElcFeeStatistics/findPreviewMicroStudentCheckList?teachingClassId=' +
            teachingClassId +
            '&calendarId=' +
            calendarId,
        method: 'post'
    });
}

/**
 *
 * 导出预览点名册
 */
function exportPreRollBookList(data) {
    return fetch({
        url: '/api/electionservice/microElcFeeStatistics/exportMicroStudentCheckList',
        method: 'post',
        data: data,
        responseType: 'blob'
    }).then(res => {
        UTILS.downloadFile(res, 'DianMingCe.xls', 'application/vnd.ms-excel;charset=utf-8');
    });
}

/**
 * 辅修选课日志导出
 */
function exportCourseLog(data) {
    return fetch({
        url: '/api/electionservice/microElcFeeStatistics/exportMicroElecLog',
        method: 'post',
        data: data
    });
}

/**
 * 辅修选课日志导出
 */
function exportCoursePay(data) {
    return fetch({
        url: '/api/electionservice/microElcFeeStatistics/export',
        method: 'post',
        data: data
    });
}

export default {
    "save": save,
    "get": get,
    'pageUrl': '/api/electionservice/microElcFeeStatistics/teachingClassResult/page',
    'payUrl': '/api/electionservice/microElcFeeStatistics/page',
    exportRollBookList: exportRollBookList,
    exportStatus: exportStatus,
    previewRollBookList: previewRollBookList,
    exportPreRollBookList: exportPreRollBookList,
    exportCourseLog: exportCourseLog,
    exportCoursePay: exportCoursePay
}